<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<style type="text/css">
    li.no_product {
        /* margin: 80px 0; */
        margin: 200px 0px 0px 0px !important;
        text-align: center;
        font-size: 33px;
        width: 100% !important;
        color: red;
    }
</style>

<c:if test="${!empty category.name}">
    <!-- 条件筛选框 -->
    <div class="module_filter">
        <div class="module_filter_line">
            <dl>
                <dt>${category.name}：</dt>
                <dd>
                    <c:forEach items="${categories}" var="category">
                        <span><a href="/render/product/list?parent_id=${category.parent_id}&id=${category.id}&pc=1">${category.name}</a></span>
                    </c:forEach>
                </dd>
            </dl>
        </div>
        <div class="bottom"></div>
    </div>
    <!-- 条件筛选框 -->
</c:if>

<!-- 显示菜单 -->
<div class="sort-bar">
    <div class="bar-l">
        <!-- 查看方式S -->
        <%--<div class="switch">
            <span class="selected">
                <a title="以方格显示" ecvalue="squares" nc_type="display_mode" class="pm" href="javascript:void(0)">大图</a>
            </span>
            &lt;%&ndash;<span style="border-left:none;">
                <a title="以列表显示" ecvalue="list" nc_type="display_mode" class="lm" href="javascript:void(0)">列表</a>
            </span>&ndash;%&gt;
        </div>--%>
        <!-- 查看方式E -->

        <!-- 排序方式S -->
        <ul class="array">
            <li class="${empty sort?'selected':''}">
                <a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=1&key=${key}" title="默认排序">默认</a>
            </li>

            <li class="${sort=='sale_count'?'selected':''}">
                <a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=1&sort=${sort=='sale_count'?'':'sale_count'}&key=${key}" title="点击按销量从高到低排序">销量</a>
            </li>

            <li class="${sort=='popularity'?'selected':''}">
                <a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=1&sort=${sort=='popularity'?'':'popularity'}&key=${key}" title="点击按人气从高到低排序">人气</a>
            </li>

            <%--<li class="${sort=='credit'?'selected':''}">
                <a href="javascript:void(0);" title="点击按信用从高到低排序">信用</a>
            </li>--%>

            <%--<li>
                &lt;%&ndash;如果上次的等于这次的，那就反过来。----> 这仅是价格&ndash;%&gt;
                <a href="/render/product/search?id=${cid}&parent_id=${parent_id}&pc=1&sort=${sort=='price'?'priceInverse':'price'}&key=${key}"
                   class="${(param.sort=="price"||param.sort=="priceInverse")?'selected':''}"
                   title="点击按价格从高到低排序">价格</a>
            </li>--%>
        </ul>
        <!-- 排序方式E -->

        <!-- 价格段S -->
        <%--<form action="javascript:void(0);" method="post">
            <div class="prices"><em>¥</em>
                <input type="text" value="" class="w30" name="min">
                <em>-</em>
                <input type="text" value="" class="w30" name="max">
                <input type="submit" value="确认" id="search_by_price">
            </div>
        </form>--%>
        <!-- 价格段E -->
    </div>
</div>
<div class="clear"></div>
<!-- 显示菜单 End -->
<!-- 商品列表 -->
<div class="shop_bd_list_content clearfix">
    <ul>
        <c:if test="${empty pb_shop.beanList}">
            <li class="no_product">对不起，没有对应店铺。</li>
        </c:if>
        <c:if test="${!empty pb_shop.beanList}">
            <c:forEach items="${pb_shop.beanList}" var="shop">
                <li>
                    <dl>
                        <dt>
                            <a href="/render/shop/queryShopByShopId?shop_id=${shop.id}">
                                <img src="${shop.user_image}"/>
                            </a>
                        </dt>
                        <dd class="title">
                            <a href="/render/shop/queryShopByShopId?shop_id=${shop.id}">
                                店名：${shop.shop_name}
                            </a>
                        </dd>
                        <dd class="content">
                            <a href="/render/shop/queryShopByShopId?shop_id=${shop.id}">
                                最近浏览量：${shop.popularity}
                            </a>
                        </dd>
                        <dd class="content">
                            <span class="goods_jiage">
                                ID：<strong>${shop.id}</strong>
                            </span>
                            <span class="goods_chengjiao">最近成交${shop.sale_count}笔</span>
                        </dd>
                    </dl>
                </li>
            </c:forEach>
        </c:if>
    </ul>
</div>

<div class="clear"></div>

<div class="pagination">
    <ul>
        <li>
            <span><a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=1&sort=${sort}&key=${key}">首页</a></span>
        </li>
        <%--上一页 --%>
        <li>
            <c:choose>
                <c:when test="${pb_shop.pc eq 1 }">
                    <span>上一页</span>
                </c:when>
                <c:otherwise>
                    <span><a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=${pb_shop.pc-1}&sort=${sort}&key=${key}">上一页</a></span>
                </c:otherwise>
            </c:choose>
        </li>

        <c:choose>
            <c:when test="${pb_shop.tp <= 6 }">
                <c:set var="begin" value="1"/>
                <c:set var="end" value="${pb_shop.tp }"/>
            </c:when>
            <c:otherwise>
                <c:set var="begin" value="${pb_shop.pc-2 }"/>
                <c:set var="end" value="${pb_shop.pc + 3}"/>
                <c:if test="${begin < 1 }">
                    <c:set var="begin" value="1"/>
                    <c:set var="end" value="6"/>
                </c:if>
                <c:if test="${end > pb_shop.tp }">
                    <c:set var="begin" value="${pb_shop.tp-5 }"/>
                    <c:set var="end" value="${pb_shop.tp }"/>
                </c:if>
            </c:otherwise>
        </c:choose>

        <c:forEach begin="${begin }" end="${end }" var="i">
            <c:choose>
                <c:when test="${i eq pb_shop.pc }">
                    <li><span class="spanBtnSelect">${i}</span></li>
                </c:when>
                <c:otherwise>
                    <li><span><a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=${i}&sort=${sort}&key=${key}" class="aBtn">${i}</a></span></li>
                </c:otherwise>
            </c:choose>
        </c:forEach>

        <c:if test="${end < pb_shop.tp }">
            <span class="spanApostrophe">...</span>
        </c:if>

        <%--下一页 --%>
        <li>
            <c:choose>
                <c:when test="${pb_shop.pc eq pb_shop.tp }">
                    <span>下一页</span>
                </c:when>
                <c:otherwise>
                    <span><a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=${pb_shop.pc+1}&sort=${sort}&key=${key}">下一页</a></span>
                </c:otherwise>
            </c:choose>
        </li>
        <li>
            <c:choose>
                <c:when test="${pb_shop.pc eq pb_shop.tp }">
                    <span>末页</span>
                </c:when>
                <c:otherwise>
                    <span><a href="/render/product/search?id=${cid}&search_key=${search_key}&parent_id=${parent_id}&pc=${pb_shop.tp}&sort=${sort}&key=${key}">末页</a></span>
                </c:otherwise>
            </c:choose>
        </li>
    </ul>
</div>
<!-- 商品列表 End -->